package com.tvein.sanguo.crowd.view
{
	//flash
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	//pureMVC
	import org.puremvc.as3.multicore.interfaces.INotification;
	import org.puremvc.as3.multicore.utilities.fabrication.patterns.mediator.FlashMediator;
	//custom
	import com.tvein.sanguo.crowd.common.GameConstants;
	import com.tvein.sanguo.crowd.model.SystemProxy;
	import com.tvein.sanguo.Crowd;
	import com.tvein.sanguo.swc.crowd.CrowdShell;
//
	public class CrowdMediator extends FlashMediator
	{
		static public const NAME:String = "CrowdMediator";
		
		public function CrowdMediator(viewComponent:Object)
		{
			super(NAME, viewComponent);
		}
		
		public function get crowd():Crowd
		{
			return viewComponent as Crowd;
		}
		
		//Custom
		private var systemData:SystemProxy;
		public var crowdShell:CrowdShell;
		
		override public function onRegister():void
		{
			systemData = facade.retrieveProxy(SystemProxy.NAME) as SystemProxy;
			
			crowd.visible = false;
			
			crowdShell = new CrowdShell(systemData.config);
			
			crowd.addChild(crowdShell);
			
			crowdShell.addEventListener("CrowdShell", _handleEvents);
		}
		
		public function _handleEvents(evt:Object):void
		{
			routeNotification(GameConstants.MODULE_INVOKE, ["-menu", ["normal", evt.cmd]], null, GameConstants.MODULE_ACTION + "/*");
		}
	}
}